<template>
<h1>员工列表页</h1>
  <el-form style="width: 500px;margin: 0 auto;" label-width="80px">
    <el-form-item label="姓名">
      <el-input v-model="user.name" placeholder="请输入员工姓名"></el-input>
    </el-form-item>
    <el-form-item label="工资">
      <el-input v-model="user.salary" placeholder="请输入员工工资"></el-input>
    </el-form-item>
    <el-form-item label="岗位">
      <el-input v-model="user.job" placeholder="请输入员工岗位"></el-input>
    </el-form-item>
  </el-form>
  <el-button @click="reg">点我提交</el-button>
  <el-table :data="arr">
    <el-table-column type="index" label="编号" align=" center" width="80"></el-table-column>
    <el-table-column label="姓名" prop="name" align=" center"></el-table-column>
    <el-table-column label="工资" prop="salary" align=" center"></el-table-column>
    <el-table-column label="岗位" prop="job" align=" center"></el-table-column>
    <el-table-column label="操作"  align=" center">
      <template v-slot="scope">
        <el-button type="danger" @click="del(scope.$index,scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<script setup>
import {ref} from "vue";

const user = ref({
  name: '',
  salary: '',
  job: ''
});
const arr = ref([
  {name: '', salary: '', job: ''},

]);
const reg = () => {
  console.log(user.value);
  arr.value.push(user.value);
};

const del = (index, row) => {
  if (confirm('确定删除' + row.name + '吗？')) {
    arr.value.splice(index, 1)
  }
};
</script>


<style scoped>

</style>